package com.hns.can.service.service;

import com.hns.can.service.vo.DriverEmotionalVo;
import com.hns.can.service.vo.EnergyVo;
import com.hns.can.common.aop.orgTree.LeftOrgAnnotation;
import com.hns.can.common.service.BaseInfoValueService;
import com.hns.frame.mybatis.Pagination;
import com.hns.frame.service.CommonService;
import com.hns.tool.pub.PubUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 驾驶心情指数service
 * @author:zhangzq
 * @email:
 * @version Revision 2.0.0
 */
@Service
public class DriverEmotionalService extends CommonService {

    @Autowired
    private BaseInfoValueService baseInfoValueService;

    /**
     * 分页查询驾驶心情指数
     * @param vo
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @LeftOrgAnnotation()
    @Transactional
    public Pagination searchDriverEmotional(EnergyVo vo)throws Exception {
        Pagination page = this.myBatisPage("driverEmotional.searchDriverEmotionalCount","driverEmotional.searchDriverEmotional", vo,DriverEmotionalVo.class);
        List<Object> list = page.getData();
        baseInfoValueService.fillOrganLineDrvName(list);
        page.setData(list);
        return page;
    }

    /**
     * 导出驾驶情绪数据
     * @param vo
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    @LeftOrgAnnotation()
    @Transactional
    @SuppressWarnings({"unchecked", "static-access" })
    public List<DriverEmotionalVo> exportDriverEmotional(EnergyVo vo) throws Exception{
        List<DriverEmotionalVo> list = PubUtil.convertListMapToObject(sqlMapDao.selectList("driverEmotional.searchDriverEmotional", vo), DriverEmotionalVo.class);
        baseInfoValueService.fillOrganLineDrvName(list);
        return list;
    }

    /**
     * 导出驾驶情绪数据用于图表分析
     * @param vo
     * @throws Exception
     * @author:zhangzq
     * @email:
     */
    public List<DriverEmotionalVo> searchDrvEmotionalInfo(EnergyVo vo) throws Exception{
        List<DriverEmotionalVo> list = PubUtil.convertListMapToObject(sqlMapDao.selectList("driverEmotional.searchDrvEmotionalInfo", vo),  DriverEmotionalVo.class);
        return list;
    }
}
